package com.pocketsweet.ui.uilib;

import com.pocketsweet.R;

import android.content.Context;
import android.text.Html;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class TagView extends LinearLayout {
	private TextView txtName;
	private ImageButton ibtnDelete;

	public TagView(Context context) {
		super(context);
		// 初始化
		init(context);
	}

	public TagView(Context context, AttributeSet attrs) {
		super(context, attrs);

		// 初始化
		init(context);
	}

	private void init(Context context) {
		View root = inflate(context, R.layout.view_tag, null);
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		addView(root, params);
		txtName = (TextView) root.findViewById(R.id.txtName);
		ibtnDelete = (ImageButton) root.findViewById(R.id.ibtnDelete);
		
	}

	@SuppressWarnings("unused")
	public void setName(String value) {
		this.txtName.setText(Html.fromHtml("<u>" + value + "</u>"));
		this.setTag(value);
	}

	@SuppressWarnings("unused")
	public ImageButton getDelet() {
		return this.ibtnDelete;
	}
}
